package com.impetus.project.skilltest.server;

import java.sql.Timestamp;
import java.util.List;

import java.util.ArrayList;

import com.impetus.project.skilltest.client.ListService;
import com.impetus.project.skilltest.client.SerializableWhiteList;
import com.impetus.project.skilltest.common.dataobject.ListData;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
public class ListServiceImpl extends RemoteServiceServlet implements
ListService{
	
	public SerializableWhiteList serializableWhiteList(SerializableWhiteList s) {
	
		throw new RuntimeException("This Method is only used to put	Beans to" +
			" the SerializationPolicy, please do not call it");
	}
	
	public List<ListData> listServer(String input) {
		String serverInfo = getServletContext().getServerInfo();
		String userAgent = getThreadLocalRequest().getHeader("User-Agent");

		ArrayList<ListData> list = new ArrayList<ListData>();
		
		ListData item = new ListData();
		item.setName("Hello, " + input + "!<br><br>I am running " + serverInfo
				+ ".<br><br>It looks like you are using:<br>" + userAgent);
		item.setTime(new Timestamp(System.currentTimeMillis()));
		list.add(item);
		
		item = new ListData();
		item.setName(input+": Test 1");
		item.setTime(new Timestamp(System.currentTimeMillis()));
		list.add(item);
		
		item = new ListData();
		item.setName(input+": Test 2");
		item.setTime(new Timestamp(System.currentTimeMillis()));
		list.add(item);
		
		item = new ListData();
		item.setName(input+": Test 3");
		item.setTime(new Timestamp(System.currentTimeMillis()));
		list.add(item);
		
		
		return list;
	}

}